package com.fcscs.cservice.domain.validator;

import com.fcscs.core.common.ErrorEnums;
import com.fcscs.core.domain.validator.BaseValidator;
import com.fcscs.cservice.domain.BookingBase;
import com.fcscs.cservice.domain.Restaurant;
import com.fcscs.cservice.domain.model.NonInHouseGuestProfile;

public interface BookingServiceValidators {

	public static class RestaurantValidator  extends BaseValidator<Restaurant> {
		public ErrorEnums validate(Restaurant entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (entity.getId() <= 0 || entity.getName() == null) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

	public static class BookingBaseValidator  extends BaseValidator<BookingBase> {
		public ErrorEnums validate(BookingBase entity, boolean newInstance) {
			ErrorEnums err = super.validate(entity, newInstance);
			if (err != null) {
				return err;
			} else {
				if (entity.getBookingStatus() == null || entity.getNumberOfGuest() <=0
						|| entity.getRestaurantId() <=0 || entity.getReservationDate() == null
						|| entity.getGuestType() == null || entity.getNotify()==null) {
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}
			}
			return null;
		}
	}

	public static class CreateBookingValidator {

		public ErrorEnums validate(BookingBase bkBase,NonInHouseGuestProfile nonInGuest){
			if(nonInGuest != null && bkBase.getGuestProfileId()<= 0){
//				nonInGuest.getEmailAddress() == null
				if(nonInGuest.getFirstName()== null || nonInGuest.getLastName() == null || nonInGuest.getPhoneNumber() == null){
					return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
				}else{
					return null;
				}
			}else if(nonInGuest != null && bkBase.getGuestProfileId() >0){
				return ErrorEnums.GeneralError.UNIQUE_CONS;
			}else if(nonInGuest == null && bkBase.getGuestProfileId() <= 0){
				return ErrorEnums.GeneralError.REQURIED_FLD_MISSING;
			}else{
				return null;
			}
		}
	}

}


